package org.fei.demo;

import com.alibaba.dubbo.rpc.RpcContext;
import org.fei.demo.api.SayHelloService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Hello world!
 *
 */
public class DemoDubboConsumerApp
{
    public static void main( String[] args )
    {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("META-INF/spring/dubbo-provider.xml");
        context.start();

        SayHelloService sayHello = context.getBean("sayHelloService", SayHelloService.class);
        System.out.println(sayHello.sayHello("Dubbo"));

        SayHelloService sayHi = context.getBean("sayHiService", SayHelloService.class);
        System.out.println(sayHi.sayHello("Dubbo"));

        System.out.println("是否是消费端："+RpcContext.getContext().isConsumerSide());
        System.out.println("服务端IP："+RpcContext.getContext().getRemoteHost());
        System.out.println("当前服务配置信息："+RpcContext.getContext().getUrl().getParameter("application"));
    }
}
